const loginService = require("../service/loginService");
const jwt = require("../util/JWT");
const controller = {
  async find(req, res) {
    const { username, password } = req.body;
    let data = await loginService.find(username, password);
    console.log(...data[0]);
    if (data[0].length) {
      let token = jwt.generate(...data[0], "1d");
      res.header("Authorization", token);
      res.send({ ok: 1 });
    } else {
      res.send({ ok: 0 });
    }
  },
};
module.exports = controller;
